<?php
require_once ("../src/db/connectdatabase.php");

function getInfoUudai($id) {
	$con = new ConnectDB();
	$tbl = "uudai";
	$fn = array('tenuudai', 'nameproduct', 'saleoff', 'ngaybatdau', 'ngayhethan', 'content', 'diachilienhe', 'bankid', 'bankname', 'banklogo', 'loaithe', 'image');
	$condetion = array('iduudai' => $id);
	return $con -> getvalue($tbl, $fn, $condetion);
}

function int_to_date($int)
{
    $time  = date("d/m/Y", $int);
    return $time;
}

if(isset($_POST['idbre'])) {
	$id = $_POST['idbre'];
	$arrres = getInfoUudai($id);
	if(count($arrres) > 0) {
		$arrres[0][3] = int_to_date($arrres[0][3]);
		$arrres[0][4] = int_to_date($arrres[0][4]);
		echo json_encode($arrres[0]);
	} else {
		echo("null");
	}
}
?>